//
// Created by user on 2022/2/21.
//
#include <vector>
using namespace std;

vector<int> sortArrayByParity(vector<int>& nums) {
    int n = nums.size();
    vector<int>res;
    res.resize(n);
    //偶数
    int index = 0;
    for (int i = 0; i < n; i++) {
        if(nums[i]%2==0){
            res[index++]=nums[i];
        }
    }
    //奇数
    for (int i = 0; i < n; ++i) {
        if(nums[i]%2==1){
            res[index++]=nums[i];
        }
    }
    return res;

}